﻿<?php
	header("Content-Type:text/html;charset=UTF-8");
	require_once 'config.php';
?>	
<html>
<head>
<title>查询卖家收到的退款列表</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src=js/colors.js></script>
</head>
<body>
<p>查询卖家收到的退款列表</p>
<p id="msgs" style="height:24px;">
<?php
	$ref =$_SERVER['SCRIPT_NAME'];
	if(empty($sessions)){
		echo 'SESSION状态：异常<a href="'.$sessionurl.$appKey.'&ref='.$ref.'">获取Session</a>';exit;
	}else{
		echo 'SESSION状态：正常 <a href="login.php?ac=logout&ref='.$ref.'">退出登陆</a>';
	}
?>
</b>
<?php
	/* Build By fhalipay */
	
/* 查询卖家收到的退款列表 Start*/

	//参数数组
	$paramArr = array(

		/* API系统级输入参数 Start */

	    	'method' => 'taobao.refunds.receive.get',  //API名称
		   'session' => $sessions, //session
	     'timestamp' => date('Y-m-d H:i:s'),			
		    'format' => 'xml',  //返回格式,本demo仅支持xml
    	   'app_key' => $appKey,  //Appkey			
	    		 'v' => '2.0',   //API版本号		   
		'sign_method'=> 'md5', //签名方式			

		/* API系统级参数 End */				 

		/* API应用级输入参数 Start*/

//	    	'fields' =>  'refund_id,tid,oid,alipay_no,total_fee,buyer_nick,seller_nick,created,modified,order_status,status,good_status,has_good_return,refund_fee,payment,reason,desc,iid,title,price,num,good_return_time,company_name,sid,address,shipping_type,refund_remind_timeout',  //返回字段
			'fields' => 'refund_id,refund_fee,tid,title,buyer_nick,seller_nick,total_fee,status,created,refund_fee,oid,good_status,company_name,sid,payment,reason,desc,has_good_return,modified,order_status',
			'status' => $status, //N 退款状态，默认查询所有退款状态的数据，除了默认值外每次只能查询一种状态。 
		'buyer_nick' => $buyer_nick, //N 买家昵称 
			  'type' => $type, //N 交易类型，默认同时查询guarantee_trade, auto_delivery的2种类型的数据，除了默认值外每次只能查询一种类型。 
	'start_modified' => $start_modified, //N 查询修改时间开始。格式: yyyy-MM-dd HH:mm:ss 
	  'end_modified' => $end_modified, //N 查询修改时间结束。格式: yyyy-MM-dd HH:mm:ss 
	       'page_no' => $page_no, //N 页码。取值范围:大于零的整数; 默认值:1 
		 'page_size' => $page_size, //N 每页条数。取值范围:大于零的整数; 默认值:40;最大值:100 
				
		/* API应用级输入参数 End*/
	);

	//生成签名
	$sign = createSign($paramArr,$appSecret);
	
	//组织参数
	$strParam = createStrParam($paramArr);
	$strParam .= 'sign='.$sign;
	
	//构造Url
	$urls = $url.$strParam;
	
	//连接超时自动重试
	$cnt=0;	
	while($cnt < 3 && ($result=@vita_get_url_content($urls))===FALSE) $cnt++;
	
	//解析Xml数据
	$result = getXmlData($result);

	//获取错误信息
	$msg = $result['msg'];
	
	//返回结果
	$refund = $result['refunds']['refund'];
	$total_results = $result['total_results'];
	
/* 查询卖家收到的退款列表 End*/	

	
?>



<form action="" method="get" name="form1" id="form1">
<table border="0" width="100%" class="table">
  <tr>
    <td>状态</td>
    <td>
	<select name="status">
    <option value="">选择</option>    

    <option value="WAIT_SELLER_AGREE">(买家已经申请退款，等待卖家同意) </option>
    <option value="WAIT_BUYER_RETURN_GOODS">(卖家已经同意退款，等待买家退货) </option>
    <option value="WAIT_SELLER_CONFIRM_GOODS">(买家已经退货，等待卖家确认收货) </option>
    <option value="SELLER_REFUSE_BUYER">(卖家拒绝退款) </option>
    <option value="CLOSED">(退款关闭) </option>
    <option value="SUCCESS">(退款成功) </option>
    </select>	
    </td>  
    <td>退款修改时间开始</td>
    <td><input type="text" name="start_modified" id="start_modified" value="2009-05-17 00:57:56"></td>
    <td>退款修改时间结束</td>
    <td><input type="text" name="end_modified" id="end_modified" value="2010-05-17 00:57:56"></td>
    <td>买家昵称</td>    
    <td><input type="text" name="buyer_nick" id="buyer_nick"></td>
  </tr>  
  <tr bgcolor="#dddddd">
    <td>交易类型</td>
    <td>
	<select name="type"> 
    <option value="">选择</option>       
    <option value="fixed">(一口价)</option>
    <option value="auction">(拍卖)</option>
    <option value="guarantee_trade">(一口价、拍卖)</option>
    <option value="auto_delivery">(自动发货)</option>
    <option value="independent_simple_trade">(旺店入门版交易)</option>
    <option value="independent_shop_trade">(旺店标准版交易)</option>
    <option value="ec">(直冲)</option>
    <option value="cod">(货到付款)</option>
    <option value="fenxiao">(分销)</option>
    <option value="game_equipment">(游戏装备)</option>
    <option value="shopex_trade">(ShopEX交易)</option>
    <option value="netcn_trade">(万网交易)</option>
    <option value="external_trade">(统一外部交易)</option>   
	</select>
    </td>


    <td colspan="6">
    <input type="submit" value="搜索订单" >
    </td>
  </tr>
</table>
</form><table border="0" width="100%" class="table">
  <tr>
    <td>退款编号</td>
    <td>订单编号</td>
    <td>宝贝名称</td>
    <td>买家</td>
    <td>交易金额</td>
    <td>退款金额</td>
    <td>申请时间</td>
    <td>修改时间</td>
    <td>退款状态</td>
    <td>操作</td>                    
  </tr>
  <?php 
  if(!empty($msg)){
  //错误信息
  	echo '<tr><td colspan=10>错误信息:'.$msg.'</td></tr>';
  }else{
  //处理正确返回信息
	if ($total_results=='0'){
	echo '<tr><td>没有合乎条件的数据</td></tr>';	
	}else if($total_results=='1'){	
  ?>  
  <tr>
    <td><?php echo $refund['refund_id'];?></td>
    <td><?php echo $refund['tid'];?></td>
    <td><?php echo $refund['title'];?></td>
    <td><?php echo $refund['buyer_nick'];?></td>
    <td><?php echo $refund['payment'];?></td>
    <td><?php echo $refund['refund_fee'];?></td>
    <td><?php echo $refund['created'];?> </td>
    <td><?php echo $refund['modified'];?> </td>
    <td><?php echo getStatus($refund['status']);?></td>
    <td><a href="taobao.refund.get.php?refund_id=<?php echo $refund['refund_id'];?>" target="_blank">查看</a></td>
  </tr>  
  <?php
	}else{
  foreach ($refund as $key => $val){
  ?>
  <tr>
    <td><?php echo $val['refund_id'];?></td>
    <td><?php echo $val['tid'];?></td>
    <td><?php echo $val['title'];?></td>
    <td><?php echo $val['buyer_nick'];?></td>
    <td><?php echo $val['payment'];?></td>
    <td><?php echo $val['refund_fee'];?></td>
    <td><?php echo $val['created'];?> </td>
    <td><?php echo $val['modified'];?></td>
    <td><?php echo getStatus($val['status']);?></td>
    <td><a href="taobao.refund.get.php?refund_id=<?php echo $val['refund_id'];?>" target="_blank">查看</a></td>
  </tr>
  <?php
  }
  }
  ?>
         
 
  <tr>
    <td colspan="15"> 
	 <?php
	// 分页 new PageClass(数据总数,每页数量,页码,URL组成);
	$pages = new PageClass($total_results,$page_size,$_GET['page'],'?'.$_SERVER['QUERY_STRING'].'&page={page}');
	echo $pages -> myde_write();
	?>    </td>
  </tr>    
</table>
<?php }?>
<p>请支持我们的网站：<a href="http://www.uscms.cn/">淘宝导购网</a> <a href="http://www.yeyoubao.com/tools">淘宝客工具</a></p>
</body>
</html>
